package com.dotc.kotlinmvvmdemo.viewModel

import android.app.Activity
import android.app.Application
import android.content.Intent
import android.util.Log
import android.view.View
import android.widget.TextView
import androidx.databinding.ObservableField
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.Observer
import com.dotc.kotlinmvvmdemo.newPackage.NewMainActivity
import com.google.android.material.tabs.TabLayout

/**
 * 数据处理
 */
class MainViewModel(application: Application) : AndroidViewModel(application) {
    var  context : Activity? = null
    val TAG = "LUO"
    val Key = ObservableField<String>("测试")
    init {
        Key.set("***欢迎光临***")
    }
    /**
     * 更新时间
     */
    fun updateTime() {
      Log.d(TAG,"======哈哈哈，时间更新了======")
    }

    fun click1(view: View,msg:String){
        Log.d(TAG,"======哈哈哈，点击click1======${msg}")
    }

    fun click2(view: View){
        Log.d(TAG,"======哈哈哈，点击click2======")
        if (view is TextView){
            view.setText("按钮2的值变化了")
        }
    }

    fun click3(){
        Log.d(TAG,"======哈哈哈，点击click3======")
    }

    fun click4(view: View){
        Log.d(TAG,"======哈哈哈，点击click4======")
    }

    fun click6(value:String){
        Log.d(TAG,"======哈哈哈，点击click6======${value}")
    }

    fun click7(value:Int){
        Log.d(TAG,"======哈哈哈，点击click7======${value}")
    }

    fun click9(value:Int,view :View){
        Log.d(TAG,"======哈哈哈，点击click9======${value}")
    }

   /* fun click10(){
        Log.d(TAG,"======点击click10,进入封装的MVVM页面======")
        context?.startActivity(Intent(context,NewMainActivity::class.java))
    }*/
}